<template>
  <div class="app-container">

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" icon="Switch" @click="SyncFile()">同步档案
        </el-button>
      </el-col>
    </el-row>

    <el-table v-loading="loading" :data="gridData" show-overflow-tooltip>
      <el-table-column prop="cateCode" label="类编编号" algin="center"/>
      <el-table-column prop="cateName" label="类别名称"  algin="center"/>
      <el-table-column prop="shangJiCode" label="上级类别编号"  algin="center"/>
      <el-table-column prop="yesOrNo" label="是否同步" algin="center"/>
    </el-table>
    <!--    <el-pagination :total="total" v-model:current-page="listQuery.page" v-model:page-size="listQuery.pageSize"-->
    <!--                   @current-change="getList"/>-->
  </div>
</template>

<script>
import request from "@/utils/request";
export default {
  name: "ImportLog",
  components: {
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      selectionList: [],
      gridData: [],
      listQuery: {
        page: 1,
        pageSize: 15,
      },
      queryParams: {
        name: null,
      },
      total: 0,
      isOptions: [{value: "0", label: "否"}, {value: "1", label: "是"}],
      typeOptions: [{value: "22432d4e-2222-4d7c-bd32-298f93567e85", label: "产品/服务段"}, {value: "d233d6e2-aa36-48d1-a81c-7f57cf395082", label: "专项项目段"}, {value: "97e723d0-0b99-4bf0-881a-f4ed214ce58e", label: "项目段"}],
      orgOptions: [{value: "59facdda-bc68-46b8-621c-5e88164c7233", label: "个人"}, {value: "d8df16ef-10d1-c459-85fd-fff03b7e7fce", label: "个体工商户"}],
    }
  },
  watch: {
  },
  created() {
    this.getList();
  },
  methods: {
    getList(){
      this.loading = true;
      request.get('formmain0108/getCategroy').then(res => {
        this.loading = false;
        // this.total = res.data.data.total
        this.gridData = res.data
        console.log(res)
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.listQuery.page = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.listQuery.page = 1;
      this.handleQuery();
    },
    SyncFile(){
      this.loading = true;
      request.post('/formmain0108/save').then(res => {
        if(res){
this.$confirm('同步成功', '提示', {
            confirmButtonText: '确定',
            showCancelButton: false, //是否显示取消按钮
            type: 'success'
          }).then(() => {
            this.getList();
          });
        }else {
          this.$confirm('同步失败，请联系管理员', '提示', {
            confirmButtonText: '确定',
            showCancelButton: false, //是否显示取消按钮
            type: 'warning'
          }).then(() => {
            this.getList();
          });
        }
      });
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      if (this.selectionList == null) {
        this.selectionList = selection;
      } else {
        this.selectionList = selection + this.selectionList
      }
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
      selection = this.selectionList;
    },
  }
}
</script>

<style scoped>

.mb8 {
  margin-bottom: 20px;
}

.app-container {
  margin: 0;
  height: 96%;
  padding: 30px 10px 10px;
  background-color: #FFFFFF;
}

</style>